import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

// 渲染主页
const Ebook = () => import('@/views/ebook/index.vue')
const EbookReader = () => import('@/components/ebook/EbookReader.vue')

// 防止重复跳转同一个路由报错
const originalPush = Router.prototype.push

Router.prototype.push = function push(location) {
	return originalPush.call(this, location).catch(err => err)
}
const routes = [{
		path: '/',
		redirect: '/ebook',
	},
	{
		path: '/ebook',
		name: 'Ebook',
		component: Ebook,
		children: [{
			path: ':fileName',
			name: 'EbookReader',
			component: EbookReader,
		}]
	},
]

const router = new Router({
	// base:'/dist/',
	mode: 'history',
	routes
})

export default router
